/**
 * 
 */
package cn.springsoter.core.mp.base;

import java.util.List;

import org.apache.commons.collections.CollectionUtils;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.common.collect.Lists;

import cn.springsoter.core.tool.api.PageResponse;

/**
 * 分页封装基类
 * 
 * @author kevin
 *
 */
public class BasePage {
	
	/**
	 * 返回分页对象
	 * 
	 * @param pageInfo
	 * @return
	 */
	public static PageResponse getPageData(IPage<?> pageInfo) {
		PageResponse<?> pageResponse = new PageResponse<>();
		pageResponse.setList(CollectionUtils.isEmpty(pageInfo.getRecords()) ? Lists.newArrayList() : (List) pageInfo.getRecords());
		pageResponse.setTotal(pageInfo.getTotal());// 总数
		pageResponse.setPage(pageInfo.getCurrent());// current page
		pageResponse.setSize(pageInfo.getSize());// page size
		return pageResponse;
	}
}
